package com.hyjoy.util;

import javax.servlet.http.Cookie;

/**
 * Created by hyjoy on 2018/4/4.
 */
public class CookieUtils {
    /**
     * 通过名称在cookie数组获取指定的cookie
     *
     * @param name    : cookie名称
     * @param cookies : cookie数组
     * @return
     */
    public static Cookie getCookieByName(String name, Cookie[] cookies) {
        if (cookies != null) {
            for (Cookie cookie : cookies) {
                // 通过名称获取
                if (name.equals(cookie.getName())) {
                    return cookie;
                }
            }
        }
        return null;
    }
}
